﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace MyATM.Common
{
    public class Utilities
    {
        /// <summary>
        /// Kiem tra tinh hop le cua chuoi nhap vao
        /// </summary>
        /// <param name="input">chuoi nhap vao</param>
        /// <param name="typeCheck">Loai chuoi: 1- CardId, 2-AccountNumber</param>
        /// <returns></returns>
      
        public bool CheckValidInput(string input, int typeCheck)
        {
            string pattern1 = "^\\d{4}$";
            string pattern2 = "^\\d{9}$";
            bool result = false;
            switch (typeCheck)
            {
                case 1:
                    Match match1 = Regex.Match(input, pattern1);
                    if(match1.Success)
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                    break;
                case 2:
                    Match match2 = Regex.Match(input, pattern2);
                    if (match2.Success)
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                    break;
                    
            }
            return result;
        }
    }
}
